{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "from pyecharts.charts  import Bar\n",
    "from pyecharts.globals import ThemeType\n",
    "from pyecharts.faker import  Faker\n",
    "from pyecharts import options as opts"
   ],
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "# 添加数据\n",
    "bar = (\n",
    "    Bar(init_opts={\n",
    "        'width': '1200px',\n",
    "        'height': '600px',\n",
    "        'theme': ThemeType.LIGHT\n",
    "    })\n",
    "    .add_xaxis(Faker.cars)\n",
    "    .add_yaxis('商家A', Faker.values())\n",
    "    .add_yaxis('商家B', Faker.values())\n",
    "    .set_global_opts(\n",
    "        xaxis_opts=opts.AxisOpts(\n",
    "            is_show=True,   # 设置的坐标轴的显示和隐藏\n",
    "            is_inverse= True  # 设置类目是否翻转\n",
    "        ),\n",
    "        yaxis_opts=opts.AxisOpts(\n",
    "            is_show= True,  #设置的坐标轴的显示和隐藏\n",
    "            axisline_opts= opts.AxisOpts(\n",
    "                is_show= True , #是否展示坐标轴线\n",
    "            ),\n",
    "            axistick_opts=opts.AxisOpts(\n",
    "                is_show= True,# 数据刻度线是否展示\n",
    "            )\n",
    "        )\n",
    "    )\n",
    ")\n"
   ],
   "id": "6972caccd4a91ce0",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "# 渲染图表\n",
    "bar.render_notebook()"
   ],
   "id": "2c13287d575c24cf",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "bar = (\n",
    "    Bar(init_opts={\n",
    "        'width': '1200px',\n",
    "        'height': '600px',\n",
    "        'theme': ThemeType.LIGHT\n",
    "    })\n",
    "    .add_xaxis(Faker.cars)\n",
    "    .add_yaxis('商家A', Faker.values())\n",
    "    .add_yaxis('商家B', Faker.values())\n",
    "    .set_series_opts(   # 系列配置项\n",
    "        itemstyle_opts=opts.ItemStyleOpts(\n",
    "            border_width=2,     # 边框线条宽度\n",
    "            border_color='red',  # 边框线条颜色\n",
    "            color='pink',     # 设置图元的颜色\n",
    "            opacity=0.6   # 设置透明度   0-1\n",
    "        )\n",
    "    )\n",
    ")\n",
    "\n",
    "bar.render_notebook()"
   ],
   "id": "23bd630be64c4162",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "from  pyecharts.charts import  Line\n",
    "line = (\n",
    "    Line(init_opts={\n",
    "        'width': '1200px',\n",
    "        'height': '600px',\n",
    "        'theme': ThemeType.LIGHT\n",
    "    })\n",
    "    .add_xaxis(Faker.cars)\n",
    "    .add_yaxis('商家A', Faker.values())\n",
    "    .add_yaxis('商家B', Faker.values())\n",
    "    .set_series_opts(   # 系列配置项\n",
    "        linestyle_opts=opts.LineStyleOpts(\n",
    "            color='pink',  # 设置折线图 线条颜色\n",
    "            width=3,    # 设置线条宽度\n",
    "            type_= 'dotted',   # 设置线型  solid  实线  dashed 虚线  dotted点线\n",
    "        )\n",
    "    )\n",
    ")\n",
    "\n",
    "line.render_notebook()"
   ],
   "id": "df8c803a1f7d2d25",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "from  pyecharts.charts import  Line\n",
    "line = (\n",
    "    Line(init_opts={\n",
    "        'width': '1200px',\n",
    "        'height': '600px',\n",
    "        'theme': ThemeType.LIGHT\n",
    "    })\n",
    "    .add_xaxis(Faker.cars)\n",
    "    .add_yaxis('商家A', Faker.values())\n",
    "    .add_yaxis('商家B', Faker.values())\n",
    "    .set_series_opts(   # 系列配置项   标签配置项\n",
    "        label_opts=opts.LabelOpts(\n",
    "            is_show= True,  # 标签展示和隐藏\n",
    "            position='top',  # 标签的位置   top  left right  bottom\n",
    "            font_size='15px',  #标签字体大小\n",
    "            font_weight='bold',  # 设置字体加粗\n",
    "            font_family='宋体',  # 字体类型 \n",
    "            # font_style='italic'   # 设置为斜体\n",
    "            rotate=-50    # 旋转标签  -90  ~ 90\n",
    "        )  \n",
    "    )\n",
    ")\n",
    "\n",
    "line.render_notebook()"
   ],
   "id": "4b0774ef6e560fd2",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "from  pyecharts.charts import  Line\n",
    "line = (\n",
    "    Line(init_opts={\n",
    "        'width': '1200px',\n",
    "        'height': '600px',\n",
    "        'theme': ThemeType.LIGHT\n",
    "    })\n",
    "    .add_xaxis(Faker.cars)\n",
    "    .add_yaxis('商家A', Faker.values())\n",
    "    .add_yaxis('商家B', Faker.values())\n",
    "    .set_series_opts(   # 系列配置项   标记点\n",
    "        markpoint_opts=opts.MarkPointOpts(\n",
    "            data=[\n",
    "                opts.MarkPointItem(type_='max',symbol_size=60),   #  标记最大值   标记的大小\n",
    "                opts.MarkPointItem(type_='min',symbol_size=60) ,  #  标记最小值   \n",
    "                opts.MarkPointItem(type_='average',symbol_size=60) ,  #  标记平均值   \n",
    "            ]\n",
    "        )\n",
    "    )\n",
    ")\n",
    "\n",
    "line.render_notebook()"
   ],
   "id": "1d85128b76526f41",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "from  pyecharts.charts import  Line\n",
    "line = (\n",
    "    Line(init_opts={\n",
    "        'width': '1200px',\n",
    "        'height': '600px',\n",
    "        'theme': ThemeType.LIGHT\n",
    "    })\n",
    "    .add_xaxis(Faker.cars)\n",
    "    .add_yaxis('商家A', Faker.values())\n",
    "    .add_yaxis('商家B', Faker.values())\n",
    "    .set_series_opts(   # 系列配置项   标记线\n",
    "       markline_opts=opts.MarkLineOpts(\n",
    "           data=[\n",
    "               # opts.MarkLineItem(type_='max',symbol_size=20),\n",
    "               # opts.MarkLineItem(type_='min',symbol_size=20),\n",
    "               opts.MarkLineItem(type_='average',symbol_size=20),\n",
    "           ],\n",
    "           linestyle_opts=opts.LineStyleOpts(\n",
    "               color='red',\n",
    "               type_='dotted',\n",
    "               width=2\n",
    "           )\n",
    "       )\n",
    "    )\n",
    ")\n",
    "\n",
    "line.render_notebook()"
   ],
   "id": "18302d81f5804315",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": "",
   "id": "6f9b8ee7149081e2",
   "outputs": [],
   "execution_count": null
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
